package br.com.toscano.contpedido.view;

import javax.inject.Inject;
import br.gov.frameworkdemoiselle.annotation.PreviousView;
import br.gov.frameworkdemoiselle.stereotype.ViewController;
import br.gov.frameworkdemoiselle.template.AbstractEditPageBean;
import br.gov.frameworkdemoiselle.transaction.Transactional;
import br.com.toscano.contpedido.business.FormaRecebimentoBC;
import br.com.toscano.contpedido.domain.FormaRecebimento;

@ViewController
@PreviousView("./formaRecebimento_list.jsf")
public class FormaRecebimentoEditMB extends AbstractEditPageBean<FormaRecebimento, Long> {

	private static final long serialVersionUID = 1L;

	@Inject
	private FormaRecebimentoBC formaRecebimentoBC;
	
	@Override
	@Transactional
	public String delete() {
		this.formaRecebimentoBC.delete(getId());
		return getPreviousView();
	}
	
	@Override
	@Transactional
	public String insert() {
		this.formaRecebimentoBC.insert(getBean());
		return getPreviousView();
	}
	
	@Override
	@Transactional
	public String update() {
		this.formaRecebimentoBC.update(getBean());
		return getPreviousView();
	}
	
	@Override
	protected FormaRecebimento handleLoad(Long id) {
		setBean(this.formaRecebimentoBC.load(id));
		
		return getBean();
	}

}